package dict

import (
	"context"

	"go-caipu/pkg/services/dto"
)

type GetSysDictTypePageCommand struct {
	dto.Pagination `search:"-"`
	DictName       string `form:"description"  search:"type:contains;column:dict_name;table:sys_dict_type" comment:""`
	Status         int64  `form:"status"  search:"type:exact;column:status;table:sys_dict_type" comment:""`
}

// SysDictType 字典类型
type SysDictType struct {
	DictId    int    `json:"id" gorm:"type:bigint;comment:DictId"`
	DictName  string `json:"name" gorm:"type:varchar(64);comment:DictName"`
	DictType  string `json:"code" gorm:"type:varchar(128);comment:DictType"`
	Status    int64  `json:"status" gorm:"type:int;comment:Status"`
	IsSystem  bool   `json:"isSystem"`
	Remark    string `json:"description" gorm:"type:varchar(255);comment:Remark"`
	CreatedAt string `json:"createTime" gorm:"comment:创建时间"`
}

func (m *GetSysDictTypePageCommand) GetNeedSearch() interface{} {
	return *m
}

type GetSysDictTypeCommand struct {
	DictId int64 `uri:"id"`
}

type RemoveSysDictTypeCommand struct {
	Ids []int64 `json:"ids"`
	Id  int64   `uri:"id"`
}

type SysDictData struct {
	DictCode  int    `json:"id" comment:""`
	DictSort  int    `json:"sort" comment:""`
	DictLabel string `json:"label" comment:""`
	DictValue string `json:"value" comment:""`
	DictType  string `json:"dictType" comment:""`
	DictId    int    `json:"dictId" comment:""`
	CssClass  string `json:"color" comment:""`
	ListClass string `json:"listClass" comment:""`
	IsDefault string `json:"isDefault" comment:""`
	Status    int    `json:"status" comment:""`
	Default   string `json:"default" comment:""`
	Remark    string `json:"description" comment:""`
	dto.ControlBy
	CreatedAt        string `json:"createTime" comment:"创建时间"`
	UpdatedAt        string `json:"updateTime" comment:"comment:创建时间"`
	CreateUserString string `json:"createUserString"` //创建人
	UpdateUserString string `json:"updateUserString"` //更新人
}
type GetSysDictDataPageCommand struct {
	dto.Pagination `search:"-"`
	DictId         int    `form:"dictId" search:"type:exact;column:dict_id;table:sys_dict_data" comment:""`
	DictLabel      string `form:"dictLabel" search:"type:contains;column:dict_label;table:sys_dict_data" comment:""`
	DictType       string `form:"dictType" search:"type:contains;column:dict_type;table:sys_dict_data" comment:""`
	DictName       string `form:"dictName"  search:"type:exact;column:dict_name;table:sys_dict_data" comment:""`
	Status         int64  `form:"status"  search:"type:exact;column:status;table:sys_dict_data" comment:""`
}

func (m *GetSysDictDataPageCommand) GetNeedSearch() interface{} {
	return *m
}

type Options struct {
	Color string `json:"color"`
	Label string `json:"label"`
	Value any    `json:"value"`
}

type GetSysDictDataCommand struct {
	Id int64 `uri:"id"`
}

type RemoveSysDictDataCommand struct {
	Ids []int64 `json:"ids"`
	Id  string  `uri:"id"`
}

// Service 业务接口
type Service interface {
	GetSysDictTypePage(ctx context.Context, cmd GetSysDictTypePageCommand) (data []SysDictType, num int64, err error)
	Get(ctx context.Context, cmd GetSysDictTypeCommand) (SysDictType, error)
	Insert(ctx context.Context, cmd SysDictType) error
	Update(ctx context.Context, cmd SysDictType) error
	Remove(ctx context.Context, cmd RemoveSysDictTypeCommand) error

	GetSysDictDataPage(ctx context.Context, cmd GetSysDictDataPageCommand) (data []SysDictData, num int64, err error)
	GetDictDataOptions(ctx context.Context, dictType string) (data []Options, err error)
	GetDictData(ctx context.Context, cmd GetSysDictDataCommand) (SysDictData, error)
	InsertDictData(ctx context.Context, cmd SysDictData) error
	UpdateDictData(ctx context.Context, cmd SysDictData) error
	RemoveDictData(ctx context.Context, cmd RemoveSysDictDataCommand) error
}
